package com.workspace.js_website.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 导航栏关键词搜索相关数据库操作
 */

@Mapper
@Repository("searchMapper")
public interface SearchMapper {
    @Select("select distinct r.name,r.describe,r.image_url,r.sort_id sort " +
            "from keyword_resource k,resources r " +
            "where k.resource_id = r.resource_id and k.name like '%${word}%'")
    List<Map<String, String> > getResource(String word);

    @Select("select distinct name from keyword_resource where name like '%${word}%' and rownum <= 6")
    List<String> getKeyword(String word);

    @Select("select distinct name,describe,image_url,sort_id sort " +
            "from resources a, smart_resource b " +
            "where a.resource_id = b.resource_id and smartcity = #{sortName}")
    List<Map<String, String> > getDataBySort(String sortName);

    @Select("select distinct p.english_abbreviation,p.describe,p.video_url,p.sort_id sort " +
            "from keyword_product k,product p " +
            "where k.product_id = p.product_id and k.name like '%${word}%'")
    List<Map<String, String>> getProduct(String word);
}
